package com.lnsoft.dqfs;

import com.lnsoft.dqfs.server.DqfsServer;
import com.lnsoft.dqfs.server.handle.threadpools.ServiceInvokePools;
import lombok.extern.slf4j.Slf4j;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.stereotype.Component;

@Component
//@Slf4j
public class ApplicationClosedListener  implements ApplicationListener<ContextClosedEvent> {

	private static final Logger log = LoggerFactory.getLogger(ApplicationClosedListener.class);
	
    @Autowired
    private DqfsServer dqfsServer;

    @Autowired
    private ServiceInvokePools serviceInvokePools;

    @Override

    public void onApplicationEvent(ContextClosedEvent contextClosedEvent) {
        log.info("应用关闭");
        serviceInvokePools.clearPools();
        dqfsServer.stop();
    }
}
